package com.ssmintegration.service.impl;

import com.ssmintegration.dao.UserDao;
import com.ssmintegration.entity.User;
import com.ssmintegration.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserDao userDao;

    @Override
    public List<User> findUser(String username) {
        return userDao.findUser(username);
    }

    @Override
    public User login(User user) {
        return userDao.login(user);
    }

    @Override
    public int register(User user) {
        if(userDao.findUserByUsername(user.getUsername()) != null){
            return 2;
        }
        return userDao.register(user);
    }

    @Override
    public int updateUser(User user) {
        return userDao.updateUser(user);
    }

    @Override
    public int deleteUser(String username) {
        return userDao.deleteUser(username);
    }

//    @Override
//    public List<User> testSearch(List<String> usernames) {
//        return userDao.testSearch(usernames);
//    }

}
